from awesum import Drawable, Cube, Vector3, Texture, Primitive, enum

class Block(Drawable):
	Type = enum("NORMAL", "BOOST", "SUPERBOOST", "REDUCE", "BREAK", "SLIDE")
	def __init__(self, v, type=0):
		super(Block, self).__init__(Drawable.Traits.GL | Drawable.Traits.COLL | Drawable.Traits.MOVE)
		self.origin = v
		self.type = type
	
	def load(self, game):
		super(Block, self).load(game)
		tex = self.game.scene.textures
		
		#Build a cube! Bounding box info is automatically generated
		if self.type == Block.Type.BOOST:
			self.gl.createCube(Primitive.Paint.TEXTURE, [tex[1], 0, 1, 2])
		elif self.type == Block.Type.SUPERBOOST:
			self.gl.createCube(Primitive.Paint.TEXTURE, [tex[1], 2])
		elif self.type == Block.Type.REDUCE:
			self.gl.createCube(Primitive.Paint.TEXTURE, [tex[1], 3, 7, 15])
		elif self.type == Block.Type.BREAK:
			self.gl.createCube(Primitive.Paint.TEXTURE, [tex[1], 9, 10, 11, 12, 13, 14])
		elif self.type == Block.Type.SLIDE:
			self.gl.createCube(Primitive.Paint.TEXTURE, [tex[0], 0])
		else:
			self.gl.createCube(Primitive.Paint.COLOR, [(1,0,0)])
		
		#Our object causes collisions but doesn't need to react itself
		self.coll.fixed = True